package com.xinchen.aiowaste.model.repository

import com.maple.base.model.BaseRepository
import com.xinchen.aiowaste.model.RetrofitClient
import com.maple.utils.util.HttpRequestUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.*

class CommonRepository : BaseRepository() {

    private val retrofitClient = RetrofitClient.service

    override fun getPublicParams(): WeakHashMap<String, Any> {
        return HttpRequestUtils.requestParams()
    }

    suspend fun login(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.login(params2Body(params))
    }

    suspend fun devInfo(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.devInfo(params2Body(params))
    }

    suspend fun envInfo(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.envInfo(params2Body(params))
    }

    suspend fun wasteList(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.wasteList(params2Body(params))
    }

    suspend fun facilityList(entId: String,status: String) = withContext(Dispatchers.IO) {
        retrofitClient.facilityList(entId,status)
    }

    suspend fun warehouseList(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.warehouseList(params2Body(params))
    }

    suspend fun storehouseList(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.storehouseList(params2Body(params))
    }

    suspend fun inboundSubmit(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.inboundSubmit(params2Body(params))
    }

    suspend fun labelInfo(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.getLabelInfo(params2Body(params))
    }

    suspend fun labelList(params: WeakHashMap<String, Any>) = withContext(Dispatchers.IO) {
        retrofitClient.getLabelList(params2Body(params))
    }
}